package com.effectivcrm;

import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.hazelcast.client.HazelcastClient;
import com.hazelcast.client.config.ClientConfig;
import com.hazelcast.config.Config;
import com.hazelcast.config.GroupConfig;

import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;

@Configuration
public class HazelcastConfiguration {
	
	
	private GroupConfig groupConfig(){
		GroupConfig grConfig = BeanUtils.instantiate(GroupConfig.class);
		grConfig.setName("effectiv");
		grConfig.setPassword("effectiv");
		
		 
		
		return grConfig;
	}
	
	
	
	private Config config() {
		Config config = BeanUtils.instantiate(Config.class);
		config.setGroupConfig(groupConfig());
		
		return config;
		
	}
	
	@Bean
	public HazelcastInstance  hazelCast() {
		return Hazelcast.newHazelcastInstance(config());
	}
	
	@Bean
	public HazelcastInstance hazelCastClient(){
		ClientConfig config = BeanUtils.instantiate(ClientConfig.class);
		config.setGroupConfig(groupConfig());
		//config.setNetworkConfig(netWorkConfig());
		return HazelcastClient.newHazelcastClient(config);
	}

	
	
	
	
	
}
